#include<bits/stdc++.h>
using namespace std;
struct car
{
    int d,v,a;
}ve[100005];
vector<int> cam[25];
bool check(float v,float a,float s,float V)
{
    if(a<0&&(v*v/(-a))<=(2*s))   {return false;}
    else    {return (v*v+2*a*s)>(V*V);}
}
void ask(int sec)
{
    memset(ve,0,sizeof(ve));
    int n,m,L,V;int cnt=0,off=0;
    scanf("%d%d%d%d",&n,&m,&L,&V);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&ve[i].d,&ve[i].v,&ve[i].a);
    }
    for(int i=1;i<=m;i++)
    {
        int p;scanf("%d",&p);
        cam[sec].push_back(p);
    }
    sort(cam[sec].begin(),cam[sec].end());
    for(int i=1;i<=n;i++)
    {
        if(ve[i].d>cam[sec][cam[sec].size()-1])  {continue;}
        if(ve[i].v<=V&&ve[i].a<=0)  {continue;}
        if(ve[i].v>V&&ve[i].a>=0)   {cnt++;continue;}
        if(ve[i].a<0)
        {
            int j=0;
            while(cam[sec][j]<ve[i].d)  {j++;}
            if(check(ve[i].v,ve[i].a,cam[sec][j]-ve[i].d,V))    {cnt++;}
        }
        else
        {
            if(check(ve[i].v,ve[i].a,cam[sec][cam[sec].size()-1]-ve[i].d,V))    {cnt++;}
        }
    }
    printf("%d ",cnt);
    return ;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    for(int i=1;i<=T;i++)   {ask(i);printf("\n");}
    return 0;
}
